-use collections::HashMap;
use std::fmt;
use std::fmt::{Show,Formatter};
+use collections::HashMap;
+use serialize::{Encoder,Encodable};
use core::{
Dependency,
NameVer,
Package,
Summary
};
-use core::errors::{CargoResult,CargoError,ToResult,PathError};
-use serialize::{Encoder,Encodable};
+use util::result::CargoResult;
-// #[deriving(Decodable,Encodable,Eq,Clone)]
#[deriving(Eq,Clone)]
pub struct Manifest {
summary: Summary,
impl TomlManifest {
pub fn to_package(&self, path: &str) -> CargoResult<Package> {
+ // TODO: Convert hte argument to take a Path
+ let path = Path::new(path);
+
// Get targets
let targets = normalize(&self.lib, &self.bin);
// Get deps
}).collect()
}).unwrap_or_else(|| vec!());
- let root = try!(Path::new(path.to_owned()).dirname_str().map(|s| s.to_owned()).to_result(|_|
- CargoError::internal(PathError(format!("Couldn't convert {} to a directory name", path)))));
+ // TODO: https://github.com/mozilla/rust/issues/14049
+ let root = Path::new(path.dirname());
Ok(Package::new(
&Manifest::new(
&Summary::new(&self.project.to_name_ver(), deps.as_slice()),
targets.as_slice(),
&Path::new("target")),
- &Path::new(root)))
+ &root))
}
}
--- /dev/null
+use std::io;
+
+pub type CargoResult<T> = Result<T, CargoError>;
+
+#[deriving(Show)]
+pub struct CargoError {
+ kind: CargoErrorKind,
+ desc: &'static str,
+ detail: Option<~str>
+}
+
+#[deriving(Show)]
+pub enum CargoErrorKind {
+ InternalError,
+ IoError(io::IoError),
+ OtherCargoError
+}
+
+type CargoCliResult<T> = Result<T, CargoCliError>;
+
+#[deriving(Show)]
+pub struct CargoCliError {
+ kind: CargoCliErrorKind,
+ exit_status: uint,
+ desc: &'static str,
+ detail: Option<~str>,
+ cause: Option<CargoError>
+}
+
+#[deriving(Show)]
+pub enum CargoCliErrorKind {
+ OtherCargoCliError
+}